﻿using Benecura.Services.WebAPI.Proxy.Common;
using System;

namespace Benecura.Services.WebAPI.Proxy
{
    public class RestProxy
    {
        #region Constants
        public enum ContentDataType
        {
            JSON,
            XML
        }

        /// <summary>
        /// Web API services end points
        /// </summary>
        public struct EndPoint
        {
            public const string Event = "event/";
        }
        #endregion

        /// <summary>
        /// Get a specific rest client default data exchange type as JSON
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T GetClient<T>(string baseUrl) where T : RestClientBase, new()
        {
            var restClient = new T();
            restClient.BaseUrl = baseUrl;
            return restClient;
        }

        /// <summary>
        /// Get a specific rest client with custom data exchange type
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="baseUrl"></param>
        /// <param name="dataType"></param>
        /// <returns></returns>
        public static T GetClient<T>(string baseUrl, ContentDataType dataType) where T : RestClientBase, new()
        {
            var restClient = new T();
            restClient.BaseUrl = baseUrl;
            restClient.SetContentDataType(dataType);
            return restClient;
        }
    }
}
